package com.chat.api.web.restctrl;

import com.chat.api.utils.ResultUtil;
import com.chat.api.utils.util.ParamUtil;
import com.chat.api.web.po.RemarkBean;
import com.chat.api.web.service.LikeService;
import com.chat.api.web.service.RemarkService;
import com.chat.api.web.vo.MessageEntity;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

@RestController
@RequestMapping("/like")
public class LikeCtrl {

    @Autowired
    private LikeService likeService;

    @RequestMapping("count")
    @ApiOperation("获取点赞数量")
    public MessageEntity list(ModelMap model,@RequestParam(value = "bId",required = false) String bId ,
                     HttpServletRequest request) {
        Long blogId = ParamUtil.getLongParameter(bId, -1L);
        return likeService.getCount(blogId,request);
    }

    @RequestMapping("clickLike")
    @ApiOperation("点赞or取消赞")
    public MessageEntity clickLike(ModelMap model,@RequestParam(value = "bId",required = false) String bId ,
                              HttpServletRequest request) {
        Long blogId = ParamUtil.getLongParameter(bId, -1L);
        return likeService.isLike(blogId,request);
    }

}
